﻿//-----------------------------------------------------------------------
// <copyright file="IActionManager.cs" company="Nathan Miller">
// Copyright (c) Nathan Miller.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
//-----------------------------------------------------------------------
namespace TileTool.Action
{
    /// <summary>
    /// Interface for a class that manages actions.
    /// 
    /// The action manager should maintain a chain of actions so that
    /// they can be done and undone by calling Redo() and Undo().
    /// </summary>
    public interface IActionManager
    {
        #region Properties

        /// <summary>
        /// Gets if the action manager can undo an action.
        /// </summary>
        bool CanUndo
        {
            get;
        }

        /// <summary>
        /// Gets if the action manager can redo an action.
        /// </summary>
        bool CanRedo
        {
            get;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Clear all actions that the action manager has.
        /// </summary>
        void Clear();

        /// <summary>
        /// Add the passed action to the manager. Action will not have Do() called on it,
        /// since it is assumed that Do() has been called prior to add.
        /// 
        /// A IActionUndoRedoMessage message will be sent that an action was added and
        /// that it had Do() called on it to account for the initial Do() call.
        /// </summary>
        /// <param name="action">Action to add.</param>
        void Add(IAction action);

        /// <summary>
        /// Do the action that is next in the action chain. Should only execute 
        /// actions whose Valid property returns true.
        /// 
        /// Must send a IActionUndoRedoMessage when the action has Do() called.
        /// </summary>
        void Redo();

        /// <summary>
        /// Undo the last action that was done.  Should only execute actions whose
        /// Valid property returns true.
        /// 
        /// Must send a IActionUndoRedoMessage when the action has Undo() called.
        /// </summary>
        void Undo();

        #endregion
    }
}
